package com.Questions.hash;


import java.util.*;

/**
 * 唯一的摩尔斯密码词
 */
public class leetcode804 {
    // 直接建立String[]来存储莫斯码

    public static final String[] MORSE = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.",
            "....", "..", ".---", "-.-", ".-..", "--", "-.",
            "---", ".--.", "--.-", ".-.", "...", "-", "..-",
            "...-", ".--", "-..-", "-.--", "--.."};
    public int uniqueMorseRepresentations(String[] words) {
        Set<String> seen=new HashSet<String>();
        for(String word:words){
            StringBuilder code=new StringBuilder();
            for(int i=0;i<word.length();++i){
                char c=word.charAt(i);
                code.append(MORSE[c-'a']);
            }
            seen.add(code.toString());
        }
        return seen.size();
    }
}
